home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.5 Applications 1999 November / SGI IRIX 6.5 Applications 1999 November.iso / dev / insight_dev.idb / usr / share / Insight / bin / clean_cgms.z / clean_cgms
Encoding:
Text File  |  1998-10-28  |  1.2 KB  |  56 lines

  1. #!/bin/sh
  2. #
  3. # fix_fig_dir sgml-file directory
  4. #
  5. # this tool looks through the book and removes extraneous CGM files
  6. # that are not needed
  7.  
  8. # verify we have a SGML file and directory name specified
  9. SGML=$1
  10. if [ "$SGML" = "" ] ; then
  11.         echo "Usage: clean_cgms sgml-file directory";
  12.         exit;
  13. fi
  14. DIR=$2
  15. if [ "$DIR" = "" ] ; then
  16.         echo "Usage: clean_cgms sgml-file directory";
  17.         exit;
  18. fi
  19.  
  20. # check to see that both exists
  21. if [ ! -f $SGML ] ; then
  22.         echo "Usage: clean_cgms sgml-file directory";
  23.     echo "       SGML file non-existant";
  24.     exit;
  25. fi
  26. if [ ! -d $DIR ] ; then
  27.         echo "Usage: clean_cgms sgml-file directory";
  28.     echo "       directory non-existant";
  29.     exit;
  30. fi
  31.  
  32. # if no cgm files then don't bother doing any more work
  33. if [ ! -f $DIR/*.cgm* ] ; then
  34.     exit;
  35. fi
  36.  
  37. if [ "$TMPDIR" = "" ] ; then
  38.         TMPDIR=/usr/tmp;
  39. fi
  40.  
  41. TMPFILE1=$TMPDIR/cgm_sgml.tmp.$$
  42. TMPFILE2=$TMPDIR/cgm_dir.tmp.$$
  43.  
  44. grep "<GRAPHIC" $SGML | sed 's/.*FILE="\(.*\)" POS.*/\1/' | sed '/<\/FIGURE>/d' | grep '\.cgm' | sort -u > $TMPFILE1
  45.  
  46. CUR_DIR=`pwd`
  47. cd $DIR
  48.  
  49. /bin/ls *.cgm* | sort -u > $TMPFILE2
  50.  
  51. EXTRA=`comm -13 $TMPFILE1 $TMPFILE2`
  52.  
  53. /bin/rm -f $EXTRA $TMPFILE1 $TMPFILE2
  54.  
  55. cd $CUR_DIR
  56.